package alogrithm;

/**
 * @author lbw
 * @version 1.0
 * @date 2021/10/19 11:43
 */
public class FindNumsAppearOnce {
    public int[] FindNumsAppearOnce(int[] array) {
        // write code here
        int tmp = 0;
        for (int i : array) {
            tmp ^= i;
        }
        int t = 1;
        while ((t & tmp) == 0) {
            t <<= 1;
        }
        int ans1 = 0;
        int ans2 = 0;
        for (int i : array) {
            if ((t & i) == 0) {
                ans1 ^= i;
            } else {
                ans2 ^= i;
            }
        }
        int[] res = new int[2];
        if (ans1 < ans2) {
            res[0] = ans1;
            res[1] = ans2;
        } else {
            res[0] = ans2;
            res[1] = ans1;
        }
        return res;
    }
}
